/******************************************************************/
/*                                                                */
/*  Winpooch : Windows Watchdog                                   */
/*  Copyright (C) 2004-2005  Benoit Blanchon                      */
/*                                                                */
/*  This program is free software; you can redistribute it        */
/*  and/or modify it under the terms of the GNU General Public    */
/*  License as published by the Free Software Foundation; either  */
/*  version 2 of the License, or (at your option) any later       */
/*  version.                                                      */
/*                                                                */
/*  This program is distributed in the hope that it will be       */
/*  useful, but WITHOUT ANY WARRANTY; without even the implied    */
/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       */
/*  PURPOSE.  See the GNU General Public License for more         */
/*  details.                                                      */
/*                                                                */
/*  You should have received a copy of the GNU General Public     */
/*  License along with this program; if not, write to the Free    */
/*  Software Foundation, Inc.,                                    */
/*  675 Mass Ave, Cambridge, MA 02139, USA.                       */
/*                                                                */
/******************************************************************/


#ifndef _CONDITION_H
#define _CONDITION_H

#include <windows.h>

#include "Reason.h"


// variants
enum {
  PARAM_ANY,
  PARAM_UINT, 
  PARAM_STRING,
  PARAM_WILDCARDS,
  PARAM_PATH,
} ;

typedef struct
{
  UINT	nSize ;
  UINT	nType ;

  union 
  {
    TCHAR	szValue[1] ;
    UINT	nValue ;		
  } ;
    
} CONDITION_PARAM ;

typedef struct
{
  UINT	nSize ;
  UINT	nReason ;
  UINT	nParams ;
  UINT	nParamsOffs[MAX_PARAMS] ; // MAX_PARAMS is defined in Reason.h
  BYTE	data[1] ;
} CONDITION ;

typedef CONDITION* LPCONDITION ;

typedef const CONDITION* LPCCONDITION ;


// Condition format string :
// s = string
// n = uint
// w = wildcards 
// p = path
// * = any

LPCONDITION	Condition_AllocAndSet (UINT nReason, LPCTSTR szFormat, ...) ;

LPCONDITION	Condition_AllocAndSetV (UINT nReason, LPCTSTR szFormat, va_list vargs) ;

//UINT		Condition_CalcDataSize (LPCTxSTR szFormat, ...) ;

UINT		Condition_CalcTotalSizeV (LPCTSTR szFormat, va_list varg) ;

UINT		Condition_CalcDataSizeV (LPCTSTR szFormat, va_list varg) ;

LPCONDITION	Condition_Dup (LPCCONDITION) ;

//BOOL		Condition_Set (LPCONDITION, UINT nReason, LPCSTR szFormat, ...) ;

BOOL		Condition_SetV (LPCONDITION, UINT nReason, LPCTSTR szFormat, va_list vargs) ;

BOOL		Condition_Check (LPCCONDITION pCondToMatch, LPCCONDITION pCond) ;

UINT		Condition_GetParamAsString (LPCCONDITION pCond, UINT iParam, LPTSTR szBuffer, UINT nSize) ;

UINT		Condition_GetParamCount (LPCCONDITION pCond) ;

LPCTSTR		Condition_GetParamString (LPCCONDITION, UINT) ;

UINT		Condition_GetParamUint (LPCCONDITION, UINT) ;

UINT		Condition_GetParamType (LPCCONDITION, UINT) ;

UINT		Condition_GetReasonAsString (LPCCONDITION, LPTSTR szBuffer, UINT nSize) ;

UINT		Condition_ToString (LPCCONDITION, LPTSTR szBuffer, UINT nSize) ;

BOOL		Condition_TestPartialKey (LPCCONDITION, LPCTSTR szPartialKey) ;

#endif
